<style lang="less">
  @import './login.less';

  .footer {
    width: 100%;
    text-align: center;
    font-size: 12px;
    color: #fff;
    line-height: 18px;
    padding: 11px 0;
    position: absolute;
    bottom: 0;
    background: black;
    opacity: 0.7;
  }
</style>

<template>
  <div class="login" @keydown.enter="handleSubmit">
    <div class="login-con">
      <Card :bordered="false">
        <p slot="title">
          <Icon type="log-in"></Icon>
          欢迎登录
        </p>
        <div class="form-con">
          <Form ref="loginForm" :model="form" :rules="rules">
            <FormItem prop="userName">
              <Input v-model="form.userName" placeholder="请输入用户名">
                            <span slot="prepend">
                                <Icon :size="16" type="md-person"></Icon>
                            </span>
              </Input>
            </FormItem>
            <FormItem prop="password">
              <Input type="password" v-model="form.password" placeholder="请输入密码">
                            <span slot="prepend">
                               <Icon :size="14" type="md-lock"></Icon>
                            </span>
              </Input>
            </FormItem>
            <FormItem>
              <Button @click="handleSubmit" type="primary" long :loading="btnLoading">登录</Button>
            </FormItem>
          </Form>
          <router-link to="/register" class="login-tip">注册账号</router-link>
          <router-link to="/forgot" class="login-tip fr">忘记密码？</router-link>
        </div>
      </Card>
    </div>

  </div>
</template>

<script>
  import {profile} from '../../../config/base'
  import {UPDATE_USER_INFO} from "../../../store/param/mutation_type";
  import Cookies from 'js-cookie'
  export default {
    data() {
      return {
        btnLoading:false,
        form: {
          userName: '',
          password: ''
        },
        rules: {
          userName: [
            {required: true, message: '账号不能为空', trigger: 'blur'}
          ],
          password: [
            {required: true, message: '密码不能为空', trigger: 'blur'}
          ]
        }
      };
    },
    methods: {
      handleSubmit() {
        this.$refs.loginForm.validate(async (valid) => {
          if (valid) {
            this.btnLoading=true
            /*let result = await login({username: this.form.userName, password: this.form.password})
            if (!result.success) {
              this.btnLoading=false
              this.$Message.error(result.msg);
              return
            }*/
            //this.$store.commit(UPDATE_USER_INFO,result.data)
            this.$Message.success('登录成功');
            this.btnLoading=false
            this.$router.push('/home')
          }
        });
      }
    },
    created() {
    }
  };
</script>
